<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>添加新闻</title>
		<%@include  file="../css.jsp"%>
		<link rel="stylesheet" href="${jpath}/static/plugins/webuploader/css/webuploader.css" />
		<link rel="stylesheet" href="${jpath}/static/plugins/webuploader/style.css" />
	
	</head>

	<body>
						<div class="page-header">
							<h1>
								新闻
								<small>
									<i class="icon-double-angle-right"></i>
									添加
								</small>
							</h1>
						</div><!-- /.page-header -->
						<div class="row">
							<div class="col-xs-12">
								<form class="form-horizontal" id="usForm"  method="post" action="" role="form">
									
									<input type="hidden" id="NewsInformationId" name="NewsInformationId" value="${newsInforList.newsInformationId }" />	
									<div class="form-group">
										<label class="col-sm-3 control-label no-padding-right" for="form-field-1">标题</label>

										<div class="col-sm-9">
											<input type="text" id="Title" name="Title" value="${newsInforList.title }" placeholder="标题" class="col-xs-10 col-sm-5" />
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-3 control-label no-padding-right" for="form-field-1">发布人</label>

										<div class="col-sm-9">
											<input type="text" id="ReleasePeople" name="ReleasePeople" value="${newsInforList.releasePeople }" placeholder="发布人" class="col-xs-10 col-sm-5" />
										</div>
									</div>
									
									<input type="hidden" id="Content" name="Content" value="${newsInforList.newsContent }" placeholder="新闻内容" class="col-xs-10 col-sm-5" />
										
									<div class="form-group" >
										<label class="col-sm-3 control-label no-padding-right" for="form-field-1">新闻内容</label>
										
										<div class="col-sm-6">
											<script type="text/javascript" charset="utf-8" src="${jpath}/static/plugins/UEditor/ueditor.config.js"></script>
										    <script type="text/javascript" charset="utf-8" src="${jpath}/static/plugins/UEditor/ueditor.all.min.js"> </script>
											<script type="text/javascript" charset="utf-8" src="${jpath}/static/plugins/UEditor/lang/zh-cn/zh-cn.js"></script>
											<script id="editor" type="text/plain" style="width:100%;height:400px;"></script>
											<script type="text/javascript">
    											var ue = UE.getEditor('editor');
    										</script>
										</div>
									    <label class="col-sm-3"></label>
									</div>
									<div class="form-group">
										<label class="col-sm-3 control-label no-padding-right" for="form-field-1">新闻栏目</label>
										<div class="col-sm-9">
											<input type="hidden" 
											on_type="comboxSelectOne" 
											id="NewsId" 
											name="NewsId"  
											no_name="ColumnName"
											value="${newsInforList.newsId }" 
											loadUrl="${jpath}/NewsContr/findByPage"
											parMs="{}"
											/>
										</div>
									</div>
									<div class="form-group">
										<div class="row">
											<label class="col-sm-3 control-label no-padding-right" for="form-field-1">新闻附件</label>
											<div class="col-sm-9">
												
											</div>
										</div>
										<div class="row">
											<div class="col-sm-3"></div>
											<div class="col-sm-9" style="width:auto !important;">
												<div class="table-responsive">
													<table id="sample-table-1" class="table table-striped table-bordered table-hover">
														<thead>
															<tr>
																<th>附件名称</th>
																<th>附件大小</th>
																<th>上传时间</th>
																<th>操作</th>
																<th>附件下载</th>
															</tr>
														</thead>
														<tbody></tbody>
													</table>
												</div><!-- /.table-responsive -->
											</div>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-3 control-label no-padding-right" for="form-field-1">附件</label>
										<input type='hidden' id='AttachmentId' name='AttachmentId'  value=""/>
										<div class="col-sm-6">
											<div id="wrapper" style="margin: 0 0 1rem -0.4rem !important ;">
										        <div id="container">
										            <!--头部，相册选择和格式选择-->
										            <div id="uploader">
										                <div class="queueList">
										                    <div id="dndArea" class="placeholder">
										                        <div id="filePicker"></div>
										                        <p>或将照片拖到这里，单次最多可选300张</p>
										                    </div>
										                </div>
										                <div class="statusBar" style="display:none;">
										                    <div class="progress">
										                        <span class="text">0%</span>
										                        <span class="percentage"></span>
										                    </div><div class="info"></div>
										                    <div class="btns">
										                        <div id="filePicker2"></div><div class="uploadBtn">开始上传</div>
										                    </div>
										                </div>
										            </div>
										        </div>
										    </div>
									    </div>
									    <label class="col-sm-3"></label>
									</div>
									<div class="clearfix form-actions" style="background-color:  #E4E6E9">
										<div class="col-md-offset-3 col-md-9">
											<button class="btn btn-info" id="submitBtn"  type="button">
												<i class="icon-ok bigger-110"></i>
												提交
											</button>

											&nbsp; &nbsp; &nbsp;
											<button class="btn" id="ss" type="reset">
												<i class="icon-undo bigger-110"></i>
												刷新
											</button>
										</div>
									</div>

								</form>
							</div><!-- /.col -->
						</div><!-- /.row -->
<%@include  file="../js.jsp"%>



<script type="text/javascript" src="${jpath}/static/plugins/webuploader/dist/webuploader.js"></script>
<script type="text/javascript" src="${jpath}/static/plugins/webuploader/upload.js"></script>
<script type="text/javascript">

	var colM = 	[{
					name:"AttachmentName"
				},{
					name:"AttachmentSize"
				},{
					name:"UploadTime"
				},{
					name:"AttachmentId",
					cl:function(index,val){
						var data="<div class='btn-group'>";
						data+="<button class='btn btn-xs btn-danger' onclick='delel(\""+val+"\")' ><i class='icon-trash bigger-120'></i></button>";
						data+="</div>";
						return data;
					}
				},{
					name:"AttachmentPath",
					cl:function(index,val){
						var data="<div class='btn-group'>";
						data+="<a class='btn btn-xs btn-info' href='${jpath}/Attachment/getFile?AttachmentPath="+val+"' target='_blank' ><i class='icon-download bigger-120'></i></a>";
						data+="</div>";
						return data;
					}
				}];
	var id=$("input[id='NewsInformationId']").val();	
	
	function delel(nowId){
		$.post("${jpath}/Attachment/Delel",{AttachmentId:nowId},function(data){
				console.log(data);
				var json=$.parseJSON(data);
				alert(json.resMsg);
				$("#sample-table-1").loadTbl(colM,{UsersId:UsersId},"${jpath}/NewsInforContr/ShowAtt",false);
			}
		);
	}
	$(function(){
		
		var NewsContent=$("#Content").val();
		
		//UE.getEditor('editor').setContent(NewsContent);
		
		$("#sample-table-1").loadTbl(colM,{NewsInformationId:id},"${jpath}/NewsInforContr/ShowAtt",false);
		
		$("#usForm").loadCombox("comboxSelectOne");
		
		$("#submitBtn").click(function(){
			var contentpar={};
			var content=UE.getEditor('editor').getContentTxt();
			contentpar.NewsContent=content;
			var jsonForms=getForm("#usForm");
			var jsonF=$.extend(contentpar,jsonForms);
			$.post("${jpath}/NewsInforContr/UpdateOrAdd",jsonF,function(data){
					console.log(data);
					var json=$.parseJSON(data);
					$("#ss").click();
					alert(json.resMsg);
					location.href="${jpath}/NewsInforContent";
				}
			);
		});
	});

	
</script>
</body>
</html>
